package webDemo;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.Map;

@WebServlet(name = "ServletDome02", value = "/ServletDome02")
public class ServletDome02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Map<String, String[]> map = request.getParameterMap();
        for (String key : map.keySet()) {
            String[] values = map.get(key);
            for (String val : values) {
                System.out.println(val);
            }
        }
        System.out.println("---------------------------------");
        String[] checkboxes = request.getParameterValues("checkbox");
        for (String checkbox : checkboxes) {
            System.out.println(checkbox);
        }
        System.out.println("---------------------------------");
        String uname = request.getParameter("uname");
        String pwd = request.getParameter("pwd");
        System.out.println("用户名是：" + uname);
        System.out.println("密码是：" + pwd);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}